package com.lik.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.websocket.server.PathParam;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class MyController {
	
	/**
	 * 测试提交
	 * @return
	 */
	@RequestMapping("/")
	public String MyMainController(){	
		System.out.println("index");
		return "Index.html";
	}
	
	@RequestMapping("/blog")
	public String BlogController(@RequestParam(value="wordId",required=false) String wordId,HttpSession session){			
		session.setAttribute("wordId", wordId);
		System.out.println("blog");
		System.out.println("wordId: " + wordId);
		return "/Blog.html";
	}
	
	@RequestMapping("/blogRequest")
	public String WordRequest(HttpSession session){
		String wordId=(String)session.getAttribute("wordId");
		switch (wordId) {
		case "1":
			System.out.println("1");
			return "/word/word1.htm";	
		case "1-1":
			System.out.println("1-1");
			return "/word/word1-1.htm";	
		case "1-2":
			System.out.println("1-2");
			return "/word/word1-2.htm";	
		default:
			System.out.println(wordId);
			return "/word/word1.htm";	
		}
		
	}
	

}
